package com.ilxqx.framework.system.service.impl;

import com.ilxqx.framework.system.entity.SysRole;
import com.ilxqx.framework.system.form.search.SysRoleSearchForm;
import com.ilxqx.framework.system.repository.SysRoleRepository;
import com.ilxqx.framework.system.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 系统角色服务实现类
 * @author venus
 */
@Service
public class SysRoleServiceImpl extends AbstractSearchableServiceImpl<SysRole, Long, SysRoleSearchForm> implements SysRoleService {

	private final SysRoleRepository sysRoleRepository;

	@Autowired
	public SysRoleServiceImpl(SysRoleRepository sysRoleRepository) {
		super(sysRoleRepository);
		this.sysRoleRepository = sysRoleRepository;
	}

	/**
	 * 创建空的或者带有默认值的实体对象
	 *
	 * @return 实体对象
	 */
	@Override
	public SysRole create() {
		return new SysRole();
	}

	/**
     * 判断名称是否存在
     *
     * @param name 名称
     * @return 存在的角色
     */
	@Override
	public SysRole nameExists(String name) {
		return this.sysRoleRepository.getByName(name);
	}

}
